package com.yssoft.controller.supervise.enterprise;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONObject;
import com.yssoft.service.core.AreaService;
import com.yssoft.service.supervise.enterprise.SuEnterpriseService;

/**
 * @author 戈超
 * @time 2018/6/08 下午 04:01
 * @  监管企业管理控制器
 */
@Controller
@RequestMapping(value = "/supervise/enterprise")
public class SuEnterpriseController {

	@Resource
	private SuEnterpriseService suEnterpriseService;
	@Resource
	private AreaService areaService;
	
	/**
	 * 跳转监管-生产企业界面
	 * @author 戈超
	 * @param model
	 * @return
	 */
	@RequestMapping("/enterprisePage")
    public String toSuEnterprise(Model model){
		String areaTree = areaService.queryAreaTree();
		model.addAttribute("areaTree", areaTree);
		return "supervise/enterprise/enterprise";
	}
	
	/**
	 * 跳转监管-生产企业界面
	 * @author 戈超
	 * @param model
	 * @return
	 */
	@RequestMapping("/queryPersonList")
    public String queryPersonList(Model model,Integer enterpriseId){
		model.addAttribute("enterpriseId",enterpriseId);
		return "supervise/enterprise/personList";
	}
	
	/**
	 * 查询监管-生产企业列表
	 * @author 戈超
	 * @param page
	 * @param limit
	 * @param name
	 * @param areaId
	 * @param isReg
	 * @return
	 */
	@ResponseBody
    @RequestMapping("/queryEnterpriseList")
    public JSONObject queryEnterpriseList(@RequestParam(name = "page",defaultValue = "0") int page,
    		@RequestParam(name = "limit",defaultValue = "10") int limit, String name, Integer areaId,
    		String isReg){
    	JSONObject pageList = suEnterpriseService.queryEnterprisePage(page, limit, name, areaId, isReg);
    	return pageList;
    }
}
